<?php foreach($messages as $message){ ?>
	<div class="f_dialog_item white">
		<div class="f_dialog_item_l small">
			<div class="u_buzz_item_l">
				<a href="<?php echo Yii::app()->createUrl('profile/index', array('id'=>$message->from));?>">
					<?php if($message->from_info->avatar_info){ ?>
						<?php echo $this->material_image('', $message->from_info->avatar_info->name, '37', 'photos/'. $message->from_info->id . '/' . 0); ?>
					<?php }else{ ?>
						<?php echo $this->material_image('', 'noimage.gif', '50', ''); ?>
					<?php } ?>				
				</a>
			</div>
			<div class="u_buzz_item_r">
				<div class="u_buzz_name">
					<a href="<?php echo Yii::app()->createUrl('profile/index', array('id'=>$message->from));?>">
						<?php if($message->from == Yii::app()->user->id){ ?>
							Я
						<?php }else{ ?>
							<?php echo CHtml::encode($message->from_info->full_name); ?>
						<?php } ?>
					</a>
					
					<?php $date_diff = date_diff(date_create($message->crdate), date_create()); ?>
					<?php if($date_diff->h){ ?>
						<p class="u_buzz_date"><?php echo Yii::app()->dateFormatter->formatDateTime($message->crdate, 'long','short'); ?></p>
					<?php }else{ ?>
						<p class="u_buzz_date"><?php echo $date_diff->i; ?> мин. назад</p>
					<?php } ?>									
				</div>
			</div>
		</div>
		<div class="f_dialog_item_r">
			<p><?php echo nl2br(CHtml::encode(rawurldecode($message->text))); ?></p>
		
			<div class="commentPhoto">
				<?php $imgClass = count($message->images)>1 ? (count($message->images)%2==0 ? 'many2' : 'many3')  : 'one' ;?>
				<?php foreach($message->images as $image){ ?>
					<?php if($image->photo){ ?>
						<div class="commentPhotoItem <?php echo $imgClass;?>">
							<a href="<?php echo Yii::app()->createUrl('albums/photo', array('id'=>$image->photo->id));?>" class="photoBg">
								<?php echo $this->material_image($image->photo->album_id, $image->photo->name, '270', 'photos/'. $message->from . '/' . $image->photo->album_id); ?>
							</a>
						</div> 
					<?php } ?>
				<?php } ?>
			</div>			
			<div class="commentVideo">
				<?php foreach($message->videos as $video){ ?>
					<div class="commentVideoItem"><?php echo $video->video->code; ?></div>
				<?php } ?>	
			</div>
			<?php if(count($message->musics)!=0){?>
			<div class="commentMusic">
				<div class="u_audio_player profileMusic">
					<?php foreach($message->musics as $music){ ?>
						<div class="u_audio__item">
							<div class="play_btn"></div>
							<div class="u_audio_track">
								<?php if($music->music->artist){ ?>
									<a href="#" data-src="<?php echo '/upload/audio/'.$music->music->music_info->file;?>" class="u_audio__autor"><?php echo $music->music->artist;?></a>
									<span> &mdash; </span>
								<?php } ?>
								<a href="#" data-src="<?php echo '/upload/audio/'.$music->music->music_info->file;?>" class="u_audio__name"><?php echo $music->music->name;?></a>
							</div>
						</div>						
					<?php } ?>	
				</div>
			</div>						
			<?php } ?>
			<div class="u_buzz_link_block hidden">
				<a href="<?php echo Yii::app()->createAbsoluteUrl("messages/deletemessage", array('message_id'=>$message->id)); ?>" onclick="return false;" class="u_buzz_link l2 delete_message">
					<div class="user_action_item_tooltip c hidden"><div class="cc">Удалить сообщение</div></div>
				</a>
			</div>
		</div>
	</div>
<?php } ?>
<script type="text/javascript">
	$(document).ready(function() {
		$('.scroll-pane').data('jsp').scrollTo(0, parseInt($('.jspPane').height()));
	});
</script>